package com.zang.netty.model.pojo;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.nio.ByteBuffer;

/**
 * @author Zhang Qiang
 * @Date 2019/7/22 8:55
 */
@Data
@Builder(toBuilder = true)
@AllArgsConstructor
@NoArgsConstructor
public class UserInfo implements Serializable {

    private static final long serialVersionUID = -875436122046146073L;
    private int id;
    private String name;

    public byte[] codeC(){
        ByteBuffer byteBuffer = ByteBuffer.allocate(1024);

        byte[] values = this.name.getBytes();
        byteBuffer.putInt(values.length);
        byteBuffer.put(values);
        byteBuffer.putInt(this.id);
        byteBuffer.flip();
        values = null;
        byte[] result = new byte[byteBuffer.remaining()];
        byteBuffer.get(result);
        return result;
    }


}
